package Offer.offer;

/**
 * 斐波那契数列
 * @author leiwenkang
 * @date 2020/4/6
 */
public class Test09斐波那契数列 {
    public int getFibonacci(int n) {
        if (n <= 0) {
            return 0;
        }
        int first = 0;
        int second = 1;

        for (int i = 2; i <= n; i++) {
            int third = first + second;
            first = second;
            second = third;
        }
        return second;
    }
}
